<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;

use mihaildev\ckeditor\CKEditor;
use mihaildev\elfinder\ElFinder;
use mihaildev\elfinder\InputFile;

/* @var $this yii\web\View */
/* @var $model app\models\Product */
/* @var $form yii\widgets\ActiveForm */

?>

<div class="product-form">

    <?php 
	$config = ['options'=>['enctype' => 'multipart/form-data']];
	$form = ActiveForm::begin($config);?>

    <?= $form->field($model, 'seoURL')->textInput(['maxlength' => 255]) ?>

    <?= $form->field($model, 'name')->textInput(['maxlength' => 255]) ?>

    <?php     
    echo $form->field($model, 'detail')->widget(CKEditor::className(), [
        'options' => ['rows' => 6],
        'editorOptions' => ElFinder::ckeditorOptions(
				'elfinder',
				['preset' => 'standard',],
				['subDir'=>Yii::$app->controller->id.'|'.$model->uploadDir]),
    ])
    
//    echo $form->field($model, 'detail')->widget(
//        TinyMce::className(),
//        ['compressorRoute' => 'test/tinyMceCompressor']
//    );
    
//    echo $form->field($model, 'detail')->widget(
//        TinyMce::className(),
//        [   'compressorRoute' => 'product/tinyMceCompressor',
//            'fileManager' => [
//                'class' => TinyMceElFinder::className(),
//                'connectorRoute' => 'elfinder/connector',
//            ],
//        ]
//    );
     ?>
    <?= $form->field($model, 'category_id')->textInput(['maxlength' => 10]) ?>

    <?= $form->field($model, 'price')->textInput(['maxlength' => 12]) ?>

    <?= $form->field($model, 'old_price')->textInput(['maxlength' => 12]) ?>
	
	<!--<input id="input-id" type="file" class="file" data-preview-file-type="text" >-->
    <img src="<?php echo $model->image?>" id="elf-thumb" class="img-thumbnail" />
    <?php 
    echo $form->field($model, 'image')->widget(InputFile::className(), [
        'controller'    => 'elfinder', // вставляем название контроллера, по умолчанию равен elfinder
        'filter'        => 'image',    // фильтр файлов, можно задать массив фильтров https://github.com/Studio-42/elFinder/wiki/Client-configuration-options#wiki-onlyMimes
        'template'      => '<div class="input-group">{input}<span class="input-group-btn">{button}</span></div>',
        'options'       => ['class' => 'form-control'],
        'buttonOptions' => ['class' => 'btn btn-default'],
        'multiple'      => false,       // возможность выбора нескольких файлов
        'query'         => ['subDir'=>Yii::$app->controller->id.'|'.$model->uploadDir]
    ]);
    ?>
    <?= $form->field($model, 'thumb')->textInput(['maxlength' => 255]) ?>

    <?= $form->field($model, 'vendor')->textInput(['maxlength' => 10]) ?>

    <?= $form->field($model, 'made_in')->textInput(['maxlength' => 100]) ?>

    <?= $form->field($model, 'new')->checkbox() ?>

    <?= $form->field($model, 'popular')->checkbox() ?>

    <?= $form->field($model, 'favorite')->checkbox() ?>

    <?= $form->field($model, 'sale')->checkbox() ?>

    <?= $form->field($model, 'tags')->textarea(['rows' => 6]) ?>

    <?= $form->field($model, 'remains')->textInput() ?>
    
    <?= $form->field($model, 'uploadDir')->hiddenInput()->label('') ?>
    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
<?php //$this->registerJsFile(Yii::$app->homeUrl."/js/fileinput.min.js",['depends' => 'yii\web\JqueryAsset','position'=>\yii\web\View::POS_END])?>